home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11899 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  872 b 

  1. Path: ghost.cbm.com!usenet
  2. From: Dave Payne <paynedc@cbm.com>
  3. Newsgroups: comp.lang.c
  4. Subject: sprintf() question
  5. Date: Wed, 27 Mar 1996 07:31:30 -0500
  6. Organization: CBM Technologies, INC
  7. Message-ID: <31593522.76B3@cbm.com>
  8. NNTP-Posting-Host: cujo.cbm.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0 (Win16; I)
  13. CC: fraleyrg@cbm.com, campbegd@cbm.com, mecimojs@cbm.com
  14.  
  15. Question on sprintf():
  16.  
  17. Is it safe, and more importantly, is it ANSI standard, to use sprintf()
  18. to print into the same variable?  Consider this example:
  19.  
  20. char foo[100] = "foobar";
  21.  
  22. sprintf(foo,"%s%s","the string is",foo);
  23.  
  24. --------------------------------------------
  25.  
  26. Would the resulting string be "the string is foobar", or will this
  27. code cause problems because I'm using the same variable (foo) to
  28. print to as well as read from?
  29.